{include file='public/head'}
<body>
<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="workOrderAdd">

        <div class="layui-form-item">
            <label class="layui-form-label"><b style="color:red">*</b>工单标题</label>
            <div class="layui-input-block">
                <input type="text" id="title" name="title" lay-verify="required" autocomplete="off"
                       placeholder="请输入工单标题" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><b style="color:red">*</b>问题类型</label>
            <div class="layui-input-block">
                <select name="category_id" id="category_id" lay-verify="required" lay-filter="category_id">
                    {volist name="category" id="vo"}
                    <option value="{$vo.id}">{$vo.category}</option>
                    {/volist}
                </select>
                <input type="hidden" id="category" name="category" value="{$category[0]['category']|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><b style="color:red">*</b>处理进度</label>
            <div class="layui-input-block">
                <select name="state_id" id="state_id" lay-verify="required" lay-filter="state_id">
                    {volist name="state" id="vo"}
                    <option value="{$vo.id}">{$vo.type}</option>
                    {/volist}
                </select>
                <input type="hidden" id="state" name="state" value="{$state[0]['type']|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">追踪号</label>
            <div class="layui-input-block">
                <input type="text" id="tracking_number" name="tracking_number" autocomplete="off"
                       placeholder="请输入追踪号" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">参考号</label>
            <div class="layui-input-block">
                <input type="text" id="reference_number" name="reference_number" autocomplete="off"
                       placeholder="请输入参考号" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-block">
                <input type="text" id="order_number" name="order_number" autocomplete="off"
                       placeholder="请输入订单编号" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">AE单号</label>
            <div class="layui-input-block">
                <input type="text" id="logistics_number" name="logistics_number" autocomplete="off"
                       placeholder="请输入AE单号" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">运输方式</label>
            <div class="layui-input-block">
                <input type="text" id="transport" name="transport" autocomplete="off"
                       placeholder="请输入运输方式" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><b style="color:red">*</b>处理期限</label>
            <div class="layui-input-block">
                <input type="text" id="deadline" name="deadline" autocomplete="off" lay-verify="required"
                       placeholder="请输入处理期限日期" class="layui-input" value="{$date}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">提交对象</label>
            <div class="layui-input-block">
                <input type="radio" name="commit" value="1" title="当前公司" checked>
                <input type="radio" name="commit" value="2" title="总公司">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>

    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">

    $(document).ready(function () {
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#deadline' //指定元素
        });
        form.on('select(category_id)', function (data) {
            $("#category").val(data.elem[data.elem.selectedIndex].text);
        });
        form.on('select(state_id)', function (data) {
            $("#state").val(data.elem[data.elem.selectedIndex].text);
        });
        var options = {
            type: 'post',           //post提交
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
        });
    });
</script>
</html>
